package snucse.teamd.math;

public class Edge {
	Vec2 v1, v2;
	Vec2 normal;
	
	public Edge(Vec2 v1_, Vec2 v2_){
		v1 = new Vec2(v1_);
		v2 = new Vec2(v2_);
		normal();
	}
	
	public Edge(Edge e) {
		v1 = new Vec2(e.getV1());
		v2 = new Vec2(e.getV2());
		normal();
	}

	
	public void print(){
		System.out.print("v1=("+v1.getX()+","+v1.getY()+")");
		System.out.print(" v2=("+v2.getX()+","+v2.getY()+")");
		System.out.println();
	}
	
	public Vec2 getNormal() {
		return normal;
	}

	private void normal(){
		normal = Vec2.minus(v1, v2).perp();
	}
	
	public double length(){
		return Vec2.distance(v1, v2);
	}

	public Vec2 getV1() {
		return v1;
	}

	public void setV1(Vec2 v1) {
		this.v1 = v1;
		normal();
	}

	public Vec2 getV2() {
		return v2;
	}

	public void setV2(Vec2 v2) {
		this.v2 = v2;
		normal();
	}
}
